package com.hzdesk.media.koreabatchmatvector.fragment.fragment_view;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.hzdesk.media.koreabatchmatvector.R;
import com.hzdesk.media.koreabatchmatvector.adapter.FileDirListAdapter;
import com.hzdesk.media.koreabatchmatvector.config.AppConfig;
import com.hzdesk.media.koreabatchmatvector.config.RxBusUtil;
import com.hzdesk.media.koreabatchmatvector.fragment.fragment_contract.FileSelectContract;
import com.hzdesk.media.koreabatchmatvector.fragment.fragment_persenter.FileSelectPersenter;
import com.hzdesk.media.koreabatchmatvector.logic.view.DialogActivity;
import com.hzdesk.media.koreabatchmatvector.utils.SDCardUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import me.zhouzhuo.zzhorizontalprogressbar.ZzHorizontalProgressBar;

/**
 * Created by Administrator on 2018/6/22.
 * 杭州席媒科技有限公司  Developers  刘传华  15
 * 佛祖镇楼 bug辟易
 */

public class FileSelectFragment extends BaseFragment implements FileSelectContract.IFileSelectView {
    @BindView(R.id.fragment_my_file_select_iv_back)
    ImageView fragmentMyFileSelectIvBack;
    @BindView(R.id.fragment_my_file_select_horizontalprogressbar)
    ZzHorizontalProgressBar fragmentMyFileSelectHorizontalprogressbar;
    @BindView(R.id.fragment_my_file_select_path)
    TextView fragmentMyFileSelectPath;
    @BindView(R.id.fragment_my_file_select_listview)
    ListView fragmentMyFileSelectListview;
    Unbinder unbinder;

    private FileSelectPersenter mFileSelectPersenter = new FileSelectPersenter(this);
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_my_file_select, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mFileSelectPersenter.initDate(fragmentMyFileSelectListview,mcontext);
    }
    @OnClick({R.id.fragment_my_file_select_iv_back, R.id.fragment_my_file_select_path})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.fragment_my_file_select_iv_back:
                mFileSelectPersenter.onClickedDialog();
                break;
            case R.id.fragment_my_file_select_path:
                mFileSelectPersenter.onClickedSelectPath();
                break;
        }
    }
    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @Override
    public void showFileSelectPath(String msg) {
        fragmentMyFileSelectPath.setText(msg);
    }

    @Override
    public void setEnabled(Boolean flag) {
        fragmentMyFileSelectPath.setEnabled(flag);
    }

    @Override
    public void setProgress(int progress) {
        fragmentMyFileSelectHorizontalprogressbar.setProgress(progress);
    }

    @Override
    public void toDialogpager() {
        Intent intent =   new Intent(mcontext, DialogActivity.class);
        intent.putExtra("Dialog_viewpage_index", RxBusUtil.CHANGE_SET_FRAGMENT);
        startActivity(intent);
    }
}
